<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head>
	<META http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Create Product</title>
	<link rel="stylesheet" href="<c:url value="/resources/blueprint/screen.css" />" type="text/css" media="screen, projection">
	<link rel="stylesheet" href="<c:url value="/resources/blueprint/print.css" />" type="text/css" media="print">
	<!--[if lt IE 8]>
		<link rel="stylesheet" href="<c:url value="/resources/blueprint/ie.css" />" type="text/css" media="screen, projection">
	<![endif]-->
</head>	

<body>
<div class="container">
	<%@include file="../common/header.jsp" %>
    <c:if test="${product.id == null}">
        <h2>Create Product</h2>
    </c:if>
    <c:if test="${product.id != null}">
        <h2>Update Product</h2>
    </c:if>

	<div class="span-12 last">	
		<form:form modelAttribute="product" action="save" method="post"  enctype="multipart/form-data" class="cleanform " >
		  	<fieldset>		
				<legend>Product information</legend>
				<p>
					<form:label	for="name" path="name" cssErrorClass="error">Product Name</form:label>
					<form:input path="name" /> <form:errors path="name" />			
				</p>
				<p>
					<form:label for="stock" path="stock" cssErrorClass="error">stock of product</form:label>
					<form:input path="stock" /> <form:errors path="stock" />
				</p>
				<p>
					<form:label for="shortdescription" path="shortdescription" cssErrorClass="error">Short Description</form:label><br/>
					<form:input path="shortdescription" /> <form:errors path="shortdescription" />
				</p>
				<p>
					<form:label for="fulldescription" path="fulldescription" cssErrorClass="error">Full Description</form:label><br/>
					<form:input path="fulldescription" /> <form:errors path="fulldescription" />
				</p>
				<p>
					<form:label for="model" path="model" cssErrorClass="error">Model</form:label>
					<form:input path="model" /> <form:errors path="model" />
				</p>
				
				<p>
				<form:label for="category" path="category">category</form:label>
				<form:select path="category.id"> 
					<form:option value="none">--- Select ---</form:option>
					<form:options items="${listcategory}" itemLabel="name"  itemValue="id" />
				</form:select>
				</p>
				
				<p>
				<form:label for="color" path="color" cssErrorClass="error">Color</form:label>
				<form:select path="color">
					<form:option value="none">--- Select ---</form:option>
					<form:option value="black">Black</form:option>
					<form:option value="white">White</form:option>
					<form:option value="gray">Gray</form:option>
				</form:select>
				</p>
				<p>
					<form:label for="price" path="price" cssErrorClass="error">Price </form:label>
					<form:input path="price" /> <form:errors path="price" />
				</p>
				<p>
					<form:label for="promotionprice" path="promotionprice" cssErrorClass="error">Promotion price </form:label>
					<form:input path="promotionprice" /> <form:errors path="promotionprice" />
				</p>
				<p>
					<form:label for="imgData1" path="imgData1">Image1</form:label>
            		<form:input path="imgData1" id="imgData1" type="file" />

				</p>
				<p>
					<form:label for="imgData2" path="imgData2">Image2</form:label>
            		<form:input path="imgData2" id="imgData2" type="file" />

				</p>
				<p>
					<form:label for="imgData3" path="imgData3">Image3</form:label>
            		<form:input path="imgData3" id="imgData3" type="file" />

				</p>
				<p>	
                    <input type="hidden" name="id" value="${product.id}" />
					<input type="submit" value="Save"/>
				</p>
			</fieldset>
		</form:form>
	</div>
	<%@include file="../common/footer.jsp" %>
</div>
</body>
</html>